var GraceJS = require("../../Grace.JS/grace.js");
import { apiServer } from '../../common.js';
Page({

    /**
     * 页面的初始数据
     */
    data: {
        id:0,
        item:{}
    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad(options) {
        var that = this;
        that.setData({
            id: options.id
        }, function(){
            that.getDetail();
        })
    },
    getDetail: function(){
        var that = this;
        GraceJS.get(
            apiServer + 'resume.Source/detail', 
            {
                id: that.data.id
            }, {},
            function (res) {
                if (res.code == 0) {
                    that.setData({
                        item: res.data
                    })
                } else {
                    GraceJS.msg(res.message)
                }
            }
        )
    },

    copy: function () {
        var that = this;
        wx.setClipboardData({
            data: that.data.item.github_url,
            success(res) {
                GraceJS.msg('已复制');
            }
        })
    },

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage: function () {
        var that = this;
        return {
            title: 'GitHub项目收录：' + that.data.item.title,
            path: '/pages/git-project-detail/index?id=' + that.data.id,
        }
    }
})